support semaphore and  memory stream